package com.aspose.cells;

import java.util.Iterator;

class zbux {
   private zane a;
   private VbaProject b;
   private zane c;

   zbux(VbaProject var1, zane var2) {
      this.b = var1;
      this.c = var2;
      this.a = var2.b("VBA");
      if (this.a == null) {
         this.a = new zane(com.aspose.cells.b.a.zh.a);
         var2.a("VBA", this.a);
      }

   }

   void a() throws Exception {
      this.d();
      this.e();
      this.f();
      this.b();
      this.c();
   }

   private void b() throws Exception {
      com.aspose.cells.b.a.d.zh var1 = new com.aspose.cells.b.a.d.zh();
      this.a(var1, 1, (int)this.b.a);
      this.a(var1, 2, (int)1033);
      this.a(var1, 20, (int)1033);
      this.a(var1, 3, (short)((short)this.b.b.i()));
      this.a(var1, 4, this.b.d, true);
      this.a(var1, 5, this.b.e, true);
      this.a(var1, 64, this.b.e, false);
      this.a(var1, 6, this.b.f, true);
      this.a(var1, 61, this.b.g, true);
      this.a(var1, 7, (int)this.b.h);
      this.a(var1, 8, (int)this.b.i);
      byte[] var2 = new byte[12];
      var2[0] = 9;
      var2[2] = 4;
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.b.j), 0, var2, 6, 4);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.b.k), 0, var2, 10, 2);
      var1.b(var2, 0, var2.length);
      this.a(var1, 12, this.b.l, true);
      this.a(var1, 60, this.b.l, false);
      Iterator var4;
      if (this.b.m != null) {
         var4 = this.b.m.iterator();

         while(var4.hasNext()) {
            byte[] var3 = (byte[])var4.next();
            var1.b(var3, 0, var3.length);
         }
      }

      this.a(var1, 15, (short)((short)this.b.getModules().getCount()));
      this.a(var1, 19, (short)this.b.getModules().b);

      for(var4 = this.b.getModules().iterator(); var4.hasNext(); this.a(var1, 43)) {
         VbaModule var6 = (VbaModule)var4.next();
         this.a(var1, 25, var6.a, true);
         this.a(var1, 71, var6.a, false);
         this.a(var1, 26, var6.c, true);
         this.a(var1, 50, var6.c, false);
         this.a(var1, 28, var6.d, true);
         this.a(var1, 72, var6.d, false);
         this.a(var1, 49, (int)var6.e);
         this.a(var1, 30, (int)var6.f);
         this.a(var1, 44, (short)((short)var6.g));
         this.a(var1, var6.h == 0 ? 33 : 34);
         if (var6.i) {
            this.a(var1, 37);
         }

         if (var6.j) {
            this.a(var1, 40);
         }
      }

      this.a(var1, 16);
      var1.b();
      var1.a(0L, 0);
      com.aspose.cells.b.a.d.zm var5 = zbuy.b(var1, 0);
      this.a.a((Object)"dir", (Object)var5);
   }

   private void a(com.aspose.cells.b.a.d.zm var1, int var2) throws Exception {
      byte[] var3 = new byte[6];
      System.arraycopy(com.aspose.cells.b.a.zc.a(var2), 0, var3, 0, 2);
      var1.b(var3, 0, 6);
   }

   private void a(com.aspose.cells.b.a.d.zm var1, int var2, short var3) throws Exception {
      byte[] var4 = new byte[8];
      System.arraycopy(com.aspose.cells.b.a.zc.a(var2), 0, var4, 0, 2);
      var4[2] = 2;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var3), 0, var4, 6, 2);
      var1.b(var4, 0, var4.length);
   }

   private void a(com.aspose.cells.b.a.d.zm var1, int var2, int var3) throws Exception {
      byte[] var4 = new byte[10];
      System.arraycopy(com.aspose.cells.b.a.zc.a(var2), 0, var4, 0, 2);
      var4[2] = 4;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var3), 0, var4, 6, 4);
      var1.b(var4, 0, var4.length);
   }

   private void a(com.aspose.cells.b.a.d.zm var1, int var2, String var3, boolean var4) throws Exception {
      Object var5 = null;
      byte[] var6 = null;
      if (var3 != null && !"".equals(var3)) {
         if (var4) {
            var6 = this.b.b.a(var3);
         } else {
            var6 = Encoding.getUnicode().a(var3);
         }
      }

      byte[] var7 = new byte[var6 == null ? 6 : 6 + var6.length];
      System.arraycopy(com.aspose.cells.b.a.zc.a(var2), 0, var7, 0, 2);
      if (var6 != null) {
         System.arraycopy(com.aspose.cells.b.a.zc.a(var6.length), 0, var7, 2, 4);
         System.arraycopy(var6, 0, var7, 6, var6.length);
      }

      var1.b(var7, 0, var7.length);
   }

   private void c() throws Exception {
      VbaModule var2;
      Object var3;
      for(Iterator var1 = this.b.getModules().iterator(); var1.hasNext(); this.a.a((Object)var2.c, (Object)var3)) {
         var2 = (VbaModule)var1.next();
         var3 = null;
         if (var2.k != null) {
            var3 = new com.aspose.cells.b.a.d.zh(var2.k);
         } else {
            var2.l = zbuy.a(var2);
            com.aspose.cells.b.a.d.zh var5 = new com.aspose.cells.b.a.d.zh();
            com.aspose.cells.b.a.d.zo var4 = new com.aspose.cells.b.a.d.zo(var5, this.b.b);
            var4.a(var2.l);
            var4.c();
            var5.a(0L, 0);
            var3 = zbuy.b(var5, 0);
         }
      }

   }

   private void d() throws Exception {
      com.aspose.cells.b.a.d.zh var1 = new com.aspose.cells.b.a.d.zh();
      com.aspose.cells.b.a.d.zo var2 = new com.aspose.cells.b.a.d.zo(var1);
      this.c.a((Object)"PROJECT", (Object)var1);
      new com.aspose.cells.b.a.d.zn(var1);
      zbuu var4 = new zbuu();
      var4.a("ID", "\"" + this.b.r + "\"");

      for(int var5 = 0; var5 < this.b.getModules().getCount(); ++var5) {
         VbaModule var6 = this.b.getModules().get(var5);
         switch(var6.h) {
         case 0:
            var4.a("Module", var6.a);
            break;
         case 1:
         default:
            var4.a("Document", var6.a + "/&H" + com.aspose.cells.a.c.zp.e(var6.b));
            break;
         case 2:
            var4.a("Class", var6.a);
            break;
         case 3:
            var4.a("BaseClass", var6.a);
         }
      }

      if (this.b.v != null) {
         var4.a(this.b.v);
      }

      if (this.b.f != null && !"".equals(this.b.f)) {
         var4.a("HelpFile", "\"" + this.b.f + "\"");
      }

      if (this.b.c != null) {
         var4.a("ExeName32", this.b.c);
      }

      var4.a("Name", "\"" + this.b.getName() + "\"");
      var4.a("HelpContextID", "\"" + com.aspose.cells.a.c.zp.a(this.b.h) + "\"");
      var4.a("VersionCompatible32", "\"" + this.b.s + "\"");
      byte[] var9 = new byte[4];
      var9[0] = (byte)(this.b.t & 255 & 7);
      var4.a("CMG", "\"" + zbuy.a(var9, this.b.r) + "\"");
      var9 = this.b.u;
      if (var9 == null) {
         var9 = new byte[1];
      }

      var4.a("DPB", "\"" + zbuy.a(var9, this.b.r) + "\"");
      var9 = new byte[]{(byte)(this.b.a() ? 255 : 0)};
      var4.a("GC", "\"" + zbuy.a(var9, this.b.r) + "\"");

      zbut var7;
      int var10;
      for(var10 = 0; var10 < var4.getCount(); ++var10) {
         var7 = var4.a(var10);
         var2.a(var7.a);
         var2.a('=');
         var2.c(var7.b);
      }

      var2.f();
      var4 = this.b.w;
      if (var4 != null && var4.getCount() > 0) {
         var2.c("[Host Extender Info]");

         for(var10 = 0; var10 < var4.getCount(); ++var10) {
            var7 = var4.a(var10);
            var2.a(var7.a);
            var2.a('=');
            var2.c(var7.b);
         }
      }

      var2.f();
      if (this.b.getModules().a()) {
         var2.c("[Workspace]");

         for(var10 = 0; var10 < this.b.getModules().getCount(); ++var10) {
            zbuw var11 = this.b.getModules().get(var10).m;
            if (var11 != null) {
               var2.a(this.b.getModules().get(var10).a);
               var2.a('=');
               StringBuilder var8 = new StringBuilder();
               var8.append(var11.a);
               var8.append(", ");
               var8.append(var11.b);
               var8.append(", ");
               var8.append(var11.c);
               var8.append(", ");
               var8.append(var11.d);
               var8.append(", ");
               switch(var11.e) {
               case 1:
                  var8.append("Z");
                  break;
               case 2:
                  var8.append("I");
                  break;
               default:
                  var8.append("C");
               }

               var2.c(com.aspose.cells.b.a.zr.a(var8));
            }
         }
      }

      var2.f();
      var2.c();
   }

   private void e() throws Exception {
      com.aspose.cells.b.a.d.zh var1 = new com.aspose.cells.b.a.d.zh();
      this.c.a((Object)"PROJECTwm", (Object)var1);
      byte[] var2 = new byte[2];

      for(int var3 = 0; var3 < this.b.getModules().getCount(); ++var3) {
         VbaModule var4 = this.b.getModules().get(var3);
         byte[] var5 = this.b.b.a(var4.a);
         var1.b(var5, 0, var5.length);
         var1.b(var2, 0, 1);
         byte[] var6 = Encoding.getUnicode().a(var4.a);
         var1.b(var6, 0, var6.length);
         var1.b(var2, 0, 2);
      }

      var1.b(var2, 0, 2);
   }

   private void f() throws Exception {
      if (!this.a.b("_VBA_PROJECT")) {
         com.aspose.cells.b.a.d.zh var1 = new com.aspose.cells.b.a.d.zh(new byte[]{-52, 97, -1, -1, 0, 1, 0});
         this.a.a((Object)"_VBA_PROJECT", (Object)var1);
      }

   }
}
